package com.yueyang.sojourn.server.model.dto;

import com.yueyang.sojourn.server.model.enums.MerchSaleTypeEnum;
import com.yueyang.sojourn.server.validation.annotation.DateFormat;
import com.yueyang.sojourn.server.validation.annotation.EnumValid;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.validation.Valid;
import javax.validation.constraints.*;
import java.util.List;

/**
 * @author yemingxing
 * @summary 新增商品dto
 * @Copyright (c) 2020, Yueyang Group All Rights Reserved.
 * @since 2020-02-17
 */
@Data
@ApiModel("新增商品信息DTO")
public class AddMerchDto {

    /**
     * 所属项目id
     */
    @ApiModelProperty(value = "所属项目id", required = true)
    @NotNull(message = "[所属项目id]不能为空")
    private Long projectId;

    /**
     * 商品标题
     */
    @ApiModelProperty(value = "商品标题", required = true)
    @NotBlank(message = "[商品标题]不能为空")
    @Size(max = 20, message = "[商品标题]最多20字")
    private String title;

    /**
     * 商品副标题
     */
    @ApiModelProperty(value = "商品副标题", required = true)
    @NotBlank(message = "[商品副标题]不能为空")
    @Size(min = 20, max = 150, message = "[商品副标题]限制20至150字")
    private String subtitle;

    @ApiModelProperty(value = "商品图片", required = true)
    @Valid
    @NotEmpty(message = "[商品图片]不能为空")
    @Size(max = 10, message = "[商品图片]最多可上传10张图片")
    private List<AttachDto> merchPic;

    /**
     * 行程路线
     */
    @ApiModelProperty(value = "行程路线", required = true)
    @NotBlank(message = "[行程路线]不能为空")
    private String travelRoute;

    /**
     * 图文描述
     */
    @ApiModelProperty(value = "图文描述", required = true)
    @NotBlank(message = "[图文描述]不能为空")
    private String desc;

    /**
     * 购买须知
     */
    @ApiModelProperty(value = "购买须知", required = true)
    @NotBlank(message = "[购买须知]不能为空")
    private String payNotice;

    /**
     * 可出行日期的开始日期
     */
    @ApiModelProperty(value = "可出行日期的开始日期", required = true, example = "2020-02-02")
    @NotBlank(message = "[可出行日期的开始日期]不能为空")
    @DateFormat(message = "[可出行日期的开始日期]格式错误")
    private String availableDateBegin;

    /**
     * 可出行日期的结束日期
     */
    @ApiModelProperty(value = "可出行日期的结束日期", required = true, example = "2020-02-20")
    @NotBlank(message = "[可出行日期的结束日期]不能为空")
    @DateFormat(isFuture = true, message = "[可出行日期的结束日期]格式错误", fieldCN = "[可出行日期的结束日期]")
    private String availableDateEnd;

    /**
     * 出行天数: 天
     */
    @NotNull(message = "[出行天数: 天]不能为空")
    @Positive(message = "[出行天数: 天]必须是正整数")
    @Max(value = 100, message = "[出行天数: 天]最大可输入100")
    private Integer days;

    /**
     * 出行天数: 晚
     */
    @NotNull(message = "[出行天数: 晚]不能为空")
    @Positive(message = "[出行天数: 晚]必须是正整数")
    @Max(value = 100, message = "[出行天数: 晚]最大可输入100")
    private Integer nights;

    /**
     * 单天库存
     */
    @NotNull(message = "[单天库存]不能为空")
    @Positive(message = "[单天库存]必须是正整数")
    @Max(value = 9999, message = "[单天库存]限制数字范围1~9999")
    @Min(value = 1, message = "[单天库存]限制数字范围1~9999")
    private Integer inventory;

    /**
     * 商品价格
     */
    @ApiModelProperty(value = "商品价格", required = true)
    @NotNull(message = "[商品价格]不能为空")
    @Positive(message = "[商品价格]必须是正数")
    private Integer price;

    /**
     * 优惠类型
     */
    @ApiModelProperty(value = "优惠类型(枚举值)")
    @EnumValid(clazz = MerchSaleTypeEnum.class, message = "[优惠类型]枚举值错误")
    private List<Integer> sales;
}
